﻿using IntelligentAgriculture.Contracts.Dto.Input.CustomerinformationSinput;
using IntelligentAgriculture.Contracts.Dto.Input.EarTagInput;
using IntelligentAgriculture.Contracts.Dto.Output.CustomerinformationSOutput;
using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;
using IntelligentAgriculture.Domain.Interface.IEarTagReposiotry;
using IntelligentAgriculture.WebAPI.Application.Command.CustomerinformationCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using IntelligentAgriculture.WebAPI.Controllers.RidgepoleController;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace IntelligentAgriculture.WebAPI.Controllers
{
    /// <summary>
    /// 客户管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CustomerinformationController : ControllerBase
    {
        private readonly IEarTagReposiotry iearTagReposiotry;
        private readonly TokenService _tokenService;
        private readonly ILogger<RidgepolesController> _logger;
        private readonly IMediator _mediator;
        public CustomerinformationController(IEarTagReposiotry iearTagReposiotry, TokenService tokenService, ILogger<RidgepolesController> logger, IMediator mediator)
        {
            this.iearTagReposiotry = iearTagReposiotry;
            _tokenService = tokenService;
            _logger = logger;
            _mediator = mediator;
        }


        /// <summary>
        /// 客户显示、分页和查询功能
        /// </summary>
        /// <param name="input">输入参数，用于指定查询条件</param>
        /// <returns>返回一个包含查询结果的异步任务结果</returns>
        [HttpGet]
        public async Task<Results<PagesOutput<CustomerinformationShowOutput>>> GetShow([FromQuery] CustomerinformationShowInput? input)
        {
            try
            {
                var list = new CustomerinformationShowCommand(input);
                return await _mediator.Send(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
